package com.users.service.impl;

import java.util.List;

import com.users.dao.UsersDaoImpl;
import com.users.entity.Users;
import com.users.service.IUsersService;

public class UsersService implements IUsersService {

	private UsersDaoImpl userDaoImpl;

	@Override
	public boolean valid(String userName, String password) {
		List<Users> list = userDaoImpl.findByUsers(userName, password);
		if(list.size()!= 0){
			return true;
		}
		return false;
	}
	
	@Override
	public List<Users> findAllUsers(Integer indexPage) {
		List<Users> list = userDaoImpl.findAllUsers(indexPage);
		return list;
	}
	
	@Override
	public List<Users> selectByName(String userName,Integer indexPage) {
		List<Users> list = userDaoImpl.findByName(userName,indexPage);
		return list;
	}

	@Override
	public Integer findAllUsers() {
		return userDaoImpl.findAllUsers();
	}
	
	@Override
	public Integer findByUserName(String userName) {
		return userDaoImpl.findByName(userName);
	}

	@Override
	public Users findUsersById(Integer usersId) {
		return userDaoImpl.get(usersId);
	}
	
	@Override
	public Integer insertUsers(Users users) {
		return userDaoImpl.save(users);
	}

	@Override
	public void deleteusers(Integer usersId) {
		userDaoImpl.delete(usersId);	
	}

	@Override
	public void updateUsers(Users users) {
		 userDaoImpl.update(users);
	}

	public UsersDaoImpl getUserDaoImpl() {
		return userDaoImpl;
	}

	public void setUserDaoImpl(UsersDaoImpl userDaoImpl) {
		this.userDaoImpl = userDaoImpl;
	}
}
